package com.example.tianling.controller;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.tianling.common.annotation.Login;
import com.example.tianling.common.annotation.LoginUser;
import com.example.tianling.common.params.ArticleCommentDo;
import com.example.tianling.common.params.InsertCommentDo;
import com.example.tianling.common.utils.Check;
import com.example.tianling.common.utils.R;
import com.example.tianling.common.vo.ArticleTrainCommentVo;
import com.example.tianling.common.vo.ArticleVo;
import com.example.tianling.common.vo.myHeInfoVo;
import com.example.tianling.entity.CommentEntity;
import com.example.tianling.entity.UserEntity;
import com.example.tianling.service.ArticleService;
import com.example.tianling.service.VideosService;
import org.json.JSONException;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@Controller
public class VideosController {
    @Autowired
    private VideosService videosService;

    //加载帖子页，需要加载这个帖子，和分页加载评论
    @Login
    @PostMapping(value="/videosList")
    @ResponseBody
    public R videosList(@LoginUser UserEntity user) {
        return R.success(videosService.getVideosList());
    }
    @Login
    @PostMapping(value="/clickVideo")
    @ResponseBody
    public R clickVideo(@RequestBody String params, @LoginUser UserEntity user) {
        JSONObject paramsJSONObject = JSONObject.parseObject(params);
        Integer videoId = paramsJSONObject.getInteger("videoId");
        return R.success(videosService.click(videoId));
    }

}
